package com.alliance.shuwei.service;

import org.springframework.stereotype.Service;

import com.qiniu.util.Auth;

@Service
public class QiniuService {
	private static String accessKey = "1Q5lvv23HnMcL39GQ21UQ29dqs0fbpNGQSFEppIz";
	private static String secretKey = "HD2vhjBuD_zcdE_HySIr-wfHzGGheBQ3FxidZgb3";
	private static String bucketName = "dyqp";
	private static String domain = "http://7xljub.com1.z0.glb.clouddn.com/";
	private static String shrink = "?imageView2/1";
	private static Auth auth = Auth.create(accessKey, secretKey);

	public String simpleUploadToken() {
		return auth.uploadToken(bucketName);
	}

	public String shrinkImage(String imageName, int width, int height) {
		String uri = domain + imageName + shrink + "/w/" + width + "/h/" + height;
		return auth.privateDownloadUrl(uri);
	}

	public String getBucketName() {
		return bucketName;
	}

	public String getDomain() {
		return domain;
	}
}
